package com.bluesky.plum.uimodels.render.html.components.menu;

import com.bluesky.javawebbrowser.domain.html.tags.Tag;
import com.bluesky.javawebbrowser.domain.html.tags.TagType;
import com.bluesky.javawebbrowser.domain.html.tags.layout.DIV;
import com.bluesky.javawebbrowser.domain.html.tags.list.UL;

public class HMenu extends
		com.bluesky.plum.uimodels.standard.components.menu.Menu {

	protected UL ul;
	protected Tag menuTag;

	public HMenu() {
		ul = new UL();
		ul.setAttribute("class", "menu-group");

		// make it float,
		ul.setStyleAttribute("float", "left");

		// add the menu name as first LI
		menuTag = new Tag(TagType.TEXT_BLOCK);

		ul.addChild(menuTag);
	}

	@Override
	public void addMenuItem(
			com.bluesky.plum.uimodels.standard.components.menu.MenuItem menuItem) {

		super.addMenuItem(menuItem);

		ul.addChild((Tag) menuItem.getNativeComponent());
	}

	@Override
	public Object getNativeComponent() {

		return ul;
	}

	@Override
	public void setCaption(String caption) {
		super.setCaption(caption);

		menuTag.setBody(caption);

	}

	public static void main(String[] args) {
		HMenu menu = new HMenu();

		Tag tag = (Tag) menu.getNativeComponent();
		System.out.println(tag.toHtml());
	}
}
